home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / owldlgs.zip / DLGNONMD.CPP < prev    next >
C/C++ Source or Header  |  1993-04-08  |  3KB  |  65 lines

  1. /**********************************************************************/
  2. /*                  Dlgnonmd.cpp by Bob Bourbonnais                   */
  3. /*              released to the public domain 12/16/91                */
  4. /*              This program demonstrates a dialog box                */
  5. /*       with a menu and two buttons that can call a non-modal        */
  6. /*      dialog box with parent from either the menu or a button.      */
  7. /*      A non-modal dialog box will not keep control.  You can go     */
  8. /*      to other windows while it is open.  A non-modal dialog box    */
  9. /*      with a parent will allways appear in front of the parent even */
  10. /*                    when the parent has the focus.                  */
  11. /**********************************************************************/
  12. #include <owl.h>
  13. #include <dialog.h>
  14. #include "dlgnonmd.h"
  15.  
  16. class TDialog5Dialog : public TDialog    // Dialog class to add
  17.   {                     // processing for menu and
  18.   public:                 // button selections
  19.     TDialog5Dialog(LPSTR lpName)         // constructor calls
  20.       :TDialog(NULL,lpName) {};         // base class constructor
  21.     virtual void HandleMenuItem(RTMessage Msg)      // menu handler
  22.       = [CM_FIRST + IDM_NON_MODAL_DIALOG];
  23.     virtual void HandleButtonMessage(RTMessage Msg) // button handler
  24.       = [ID_FIRST + IDB_NON_MODAL_DIALOG];   // close button handled by
  25.   };                                     // base class button handler
  26. void TDialog5Dialog:: HandleMenuItem(RTMessage)
  27.   {
  28.   GetApplication()->MakeWindow(new TDialog(this,"Non_Modal_Dialog_Box"));
  29.   }               //MakeWindow activates a non-modal dialog box with parent
  30. void TDialog5Dialog:: HandleButtonMessage(RTMessage)
  31.   {
  32.   GetApplication()->MakeWindow(new TDialog(this,"Non_Modal_Dialog_Box"));
  33.   }
  34.  
  35. class TDialog5App : public TApplication  // Application Class to contain
  36.   {                                      // the application
  37.   public:
  38.     TDialog5App(LPSTR lpName, HANDLE hInstance,  // constructor calls the
  39.         HANDLE hPrevInstance,            // base class constructor
  40.         LPSTR lpCmdLine, int nCmdShow)
  41.         :TApplication(lpName, hInstance,
  42.                   hPrevInstance,
  43.                   lpCmdLine, nCmdShow) {};
  44.  
  45.     virtual void InitMainWindow(); // overrides base class InitMainWindow
  46.   };
  47.  
  48. void TDialog5App::InitMainWindow() // to initialize a dialog box
  49.   {                                // as the main window
  50.   MainWindow = new TDialog5Dialog("Main_Window_Dialog");
  51.   }                                // using message processing provided
  52.                    // by derived class
  53.  
  54. int PASCAL WinMain(HANDLE hInstance,              // main entry point from
  55.            HANDLE hPrevInstance,          // windows to this program
  56.            LPSTR lpCmdLine , int nCmdShow)
  57.   {
  58.   TDialog5App Dialog5("Dialog Tester",hInstance,  // create instance of
  59.                hPrevInstance,             // the dialog application
  60.                lpCmdLine,nCmdShow);
  61.   Dialog5.Run();                                  // run it
  62.   return (Dialog5.Status);                        // exit
  63.   }
  64. /**********************************************************************/
  65.